package com.mk.legoscans2.data;

import java.util.List;

public class FavoritesService {
	
	private FavoritesRepositoryFactory _favoritesRepositoryFactory;
	private AccountService _accountService;
	
	public FavoritesService(FavoritesRepositoryFactory favoritesRepositoryFactory, AccountService accountService)
	{
		_favoritesRepositoryFactory = favoritesRepositoryFactory;
		_accountService = accountService;
	}
	
	public List<String> getFavorites(String selectedAccount) {
		
		FavoritesRepository repository = _favoritesRepositoryFactory.getRepository(selectedAccount);
		return repository.getFavorites();
	}
	
	public boolean toggleFavorite(String selectedAccount, String scanId)
	{
		FavoritesRepository repository = _favoritesRepositoryFactory.getRepository(selectedAccount);
		return repository.toggleFavorite(scanId);
	}
	
	public boolean isFavorite(String scanId)
	{
		return isFavorite(_accountService.getAccount(), scanId);
	}
	
	public boolean isFavorite(String selectedAccount, String scanId)
	{
		FavoritesRepository repository = _favoritesRepositoryFactory.getRepository(selectedAccount);
		return repository.isFavorite(scanId);
	}
}
